package com.student.servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.student.dao.CourseDao;
import com.student.model.Course;

@WebServlet("/ShowAllSelectCourseServlet")
public class ShowAllSelectCourseServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public ShowAllSelectCourseServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		CourseDao cd = new CourseDao();
		List<Course> allSelectCourseList = null;
		HttpSession session = request.getSession();
		try {
			allSelectCourseList = cd.getAllSelectCourseList();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		request.setAttribute("allSelectCourseList", allSelectCourseList);
		session.setAttribute("allSelectCourseList", allSelectCourseList);
		request.getRequestDispatcher("/view/teacher/courseList.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
